import { ref } from 'vue'
import { defineStore } from 'pinia'
import {head,banner,news,hot,brand,goods} from '../apis/home'

export const useCounterStore = defineStore('counter', () => {
  const header = ref(null)
  const bannerList=ref(null)
  const newList=ref(null)
  const hotList=ref(null)
  const brandList=ref(null)
  const goodsList=ref(null)
  const categorylist=ref(null)

  const categoryHead=async()=>{
    const data=await head()
    header.value=data.result
  }
  
  const getbannerList=async()=>{
    const data=await banner()
    bannerList.value=data.result
  }

  const getnews=async()=>{
    const data=await news()
    newList.value=data.result
  }

  const gethot=async()=>{
    const data=await hot()
    hotList.value=data.result
  }

  const getbrand=async(num)=>{
    const data=await brand(num)
    brandList.value=data.result
  }

  const getgoodsList=async()=>{
    const data=await goods()
    goodsList.value=data.result
  }

  const getcategoryList=async (id)=>{
    console.log(id);
    
    const data=await category(id)
    categorylist.value=data.result
  }
  return { header,bannerList,newList,hotList,brandList,goodsList,categorylist,gethot,categoryHead,getbannerList,getnews,getbrand,getgoodsList,getcategoryList}
})
